<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .red{
            border: 1px solid red;
        }
    </style>
</head>
<body>
<form action="/valid_check" th:object="${stu2}">
    name:<input type="text" th:field="*{name}"><br>
    <p th:if="${#fields.hasErrors('name')}" th:errors="*{name}"></p>
    java:<input type="text" th:field="*{java}"><br>
    math:<input type="text" th:field="*{math}"><br>
    age:<input type="text" th:field="*{age}"><br>
    address.city:<input type="text" th:field="*{address.city}"><br>
    <input type="submit">
<!--    显示校验的错误信息-->
    <ul th:if="${#fields.hasErrors('*')}">
        <li th:each="err : ${#fields.errors('*')}" th:text="${err}">Input is incorrect</li>
    </ul>
</form>
</body>
</html>